<template>
  <div>
    <el-badge
      v-for="num in randomQuestion.length"
      :key="num"
      :value="num < 10 ? '0' + num : num"
      class="item"
      :type="num == index + 1 ? 'success' : 'info'"
      @click.native="goToNum(num - 1)"
    >
    </el-badge>
  </div>
</template>

<script>
import { mapState, mapMutations, mapActions } from "vuex";
export default {
  data() {
    return {};
  },
  computed: {
    ...mapState("test/questions", ["index", "randomQuestion"]),
  },
  methods: {
    ...mapMutations("test/questions", ["SET_INDEX"]),
    ...mapActions("test/questions", ["randomQuestionDataFn"]),
    goToNum(num) {
      this.SET_INDEX(num);
    },
  },
  async mounted() {
    if (!this.randomQuestion) {
      await this.randomQuestionDataFn();
    }
    console.log(this.randomQuestion);
  },
};
</script>

<style scoped>
</style>